//
//  XJUserAccountModel.m
//  weiboOC
//
//  Created by 徐绩 on 16/4/21.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "XJUserAccountModel.h"

@implementation XJUserAccountModel

-(instancetype)initWithDict:(NSDictionary *)dict{

    if (self = [super init]) {
        
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}

+(instancetype)accountModelWithDict:(NSDictionary *)dict{

    return [[self alloc]initWithDict:dict];
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{}

-(void)setExpires_in:(NSTimeInterval )expires_in{

    self.expiresDate = [NSDate dateWithTimeIntervalSinceNow:expires_in];
}

/**
 *  归档
 */
- (void)encodeWithCoder:(NSCoder *)aCoder{

    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.remind_in forKey:@"remind_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:self.avatar_large forKey:@"avatar_large"];
    [aCoder encodeObject:self.expiresDate forKey:@"expiresDate"];
    

}
/**
 *  解档
 */
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        
        self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.remind_in = [aDecoder decodeObjectForKey:@"remind_in"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.avatar_large = [aDecoder decodeObjectForKey:@"avatar_large"];
        self.expiresDate = [aDecoder decodeObjectForKey:@"expiresDate"];
        
    }
    return self;
}

@end
